package com.project.JunM.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.JunM.entity.SPay;
import com.project.JunM.entity.SPayDetails;
import com.project.JunM.mapper.SPayDetailsMapper;
import com.project.JunM.service.SPayDetailsService;
import com.project.common.entity.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class SPayDetailsImpl implements SPayDetailsService {
    @Autowired
    private SPayDetailsMapper sPayDetailsMapper;
    @Override
    public int insertSelective(SPayDetails record) {
        return sPayDetailsMapper.insertSelective(record);
    }

    @Override
    public List<SPayDetails> querySPayDetailsAll(Integer parentId) {
        return sPayDetailsMapper.querySPayDetailsAll(parentId);
    }

    @Override
    public List<SPayDetails> querySPayDetailsCheckInAll(Integer parentId) {
        return sPayDetailsMapper.querySPayDetailsCheckInAll(parentId);
    }

    @Override
    public int updateSPayDetailsByProductId(SPayDetails record) {
        return sPayDetailsMapper.updateSPayDetailsByProductId(record);
    }

    @Override
    public SPayDetails querySPayDetailsByParentIdByProductId(SPayDetails sPayDetails) {
        return sPayDetailsMapper.querySPayDetailsByParentIdByProductId(sPayDetails);
    }

    @Override
    public SPayDetails querySPayDetailsByParentIdByProductId1(Integer pId, String productId) {
        return sPayDetailsMapper.querySPayDetailsByParentIdByProductId1(pId, productId);
    }

    @Override
    public SPayDetails selectByProductId(SPayDetails sPayDetails) {
        return sPayDetailsMapper.selectByProductId(sPayDetails);
    }

    @Override
    public PageVo<SPayDetails> queryDynamicInventoryAll(Map<String, String> map) {

        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));

        PageHelper.startPage(pageNum,pageSize);
        List<SPayDetails> sPayDetailsList = sPayDetailsMapper.queryDynamicInventoryAll();
        PageInfo pageInfo = new PageInfo(sPayDetailsList);

        PageVo pageVo = new PageVo();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }

    @Override
    public int updateByPrimaryKeySelective(SPayDetails record) {
        return sPayDetailsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<SPayDetails> querySPayDetails() {
        return sPayDetailsMapper.querySPayDetails();
    }
}
